package com.junqi.media.mq;

import com.junqi.common.constant.MQConstant;
import com.junqi.common.entity.RoomLiveMq;
import com.junqi.media.hls.HlsHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 关播mq监听
 */
@Component
@Slf4j
@RocketMQMessageListener(topic = MQConstant.ROOM_CLOSE_PLAY_TOPIC,consumerGroup = MQConstant.ROOM_CLOSE_PLAY_GROUP)
public class ClosePlayMQComsumer implements RocketMQListener<RoomLiveMq> {

    @Autowired
    HlsHandler hlsHandler;

    @Override
    public void onMessage(RoomLiveMq dto) {
        log.warn("mq消费消息，关播，roomId=[{}]", dto.getRoomId());
        hlsHandler.endHls(dto.getRoomId());
    }

}
